# 集合推导式

"""


"""

varset = {1, 2, 3, 4}

# (1) 普通推导式 返回一个新的集合
newset = {i*2 for i in varset}
# {8, 2, 4, 6}

# (2) 带有条件表达式的推导式
newset = {i*2 for i in varset if i % 2 == 0}
# {8, 4}

# (3) 多循环集合推导式
varset2 = {4, 5, 6}
newset = {i+j for i in varset for j in varset2}
# {5, 6, 7, 8, 9, 10}

newset = {i+j for i in varset for j in varset2 if i == j}
# {8}

print(newset)
